home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Nov 90 / MacApp.Tech$ 11⁄9⁄90 / 2311-Re HELP, EachSubView-Nov90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.9 KB  |  54 lines  |  [TEXT/GEOL]

  1. Item    1147123                         4-Nov-90        13:02PST
  2.  
  3. From:   V0683                           Amoco Tech, Eric Berdahl,VAR
  4.  
  5. To:     GER.XSE0096                     Germany - Ciechowski Computer,IDV
  6.         MACAPP.TECH$                    MacApp Technical
  7.  
  8. Sub:    Re: HELP, EachSubView via C++…
  9.  
  10. Ingo,
  11.  
  12. Because you are using C++ and MacApp is "using" Pascal concepts, you must
  13. emulate those concepts in your code.  The one concept you've stumbled on here
  14. is the use of local procedures.  Normally, you'd do something like this in
  15. pascal.
  16.  
  17. PROCEDURE TMAMandat.DoMakeViews(forPrinting: Boolean);
  18.     VAR
  19.         status: TWindow;
  20.     PROCEDURE init_it(view: TView);
  21.     VAR
  22.         zwerg: String;
  23.     BEGIN
  24.         zwerg := gMaster.GetData(view.fIdentifier);
  25.         TStaticText(view).SetText(zwerg, false);
  26.     END;
  27. BEGIN
  28.     IF NOT forPrinting THEN
  29.         BEGIN
  30.             status := NewTemplateWindow(WiDMaStatus, SELF);
  31.             FailNIL(status);
  32.             TView(status).fDocument := SELF;
  33.             TView(status).EachSubView(init_it);
  34.             status.Open;
  35.         END;
  36. END;
  37.  
  38. Notice that the Pascal version of your routine has no second argument for
  39. EachSubView, or at least not one you can see.  Since init_it is a local
  40. procedure, it has access to all the local variables of its enclosing procedure,
  41. DoMakeViews.  The way pascal handles this is to pass the A6 register, called
  42. the "static link", as a parameter.  Thus, init_it has a base from which to
  43. reference the local variables of DoMakeViews.  Since C++ has no similar
  44. concept, you may pass anything there.  Some people like passing this, others
  45. create a struct that contains copies of the variables they want to access and
  46. pass its address.  It's entirely up to you.  I suggest that you read Tech Note
  47. 265 - Pascal to C: PROCEDURE parameters.
  48.  
  49. Hope this helps,
  50. Eric Berdahl
  51. Amoco Technology Company
  52. AppleLink:  V0683
  53.  
  54.